// pages/Mine/UserInfo/UserInfo.js

/**picker***/
var model = require('../../../component/area/model.js')
var show = false;
var item = {};
/**picker***/

Page({

  /**
   * 页面的初始数据
   */
  data: {
    startDate: '2016-09-26',
    year: '2017',
    month: '02',
    day: '03',
    addressText: '省市县',
    items: [
      { name: 'Man', value: '男', checked: 'true' },
      { name: 'Woman', value: '女'},
    ],
    item: {
      show: show
    },
  },
  
  
  listenerDatePickerSelectedStart: function (e) {
    this.setData({
      year: e.detail.value.split("-")[0],
      month: e.detail.value.split("-")[1],
      day: e.detail.value.split("-")[2]
    })
  },

  // 获取该组件的id  
  radio: function (e) {
    this.setData({
      guige_key02: e.currentTarget.dataset.id
    })
    // console.log(e.currentTarget.dataset.id)
  },
  // 获取用户选择的单选框的值  
  radioChange: function (e) {
    this.setData({
      arr_guige02: e.detail.value
    })
    console.log(e.detail.value)
  },  

  /**
   * 选择地址 picker
   */
  selectAddress: function (e) {
    this.pickup();
  },

  pickup: function (e) {
    var that = this;
    model.pickup(this, "", "", "", function (result) {
      that.setData({
        item: result
      });
    })
  },
  //取消或者 隐藏picker-view
  hiddenFloatView: function (e) {
    var that = this;
    model.pickDown(this, function (result) {
      that.setData({
        item: result
      });
    })
  },
  //选取了值，再隐藏view
  okFloatView: function (e) {
    var that = this;
    model.pickDown(this, function (result) {
      that.setData({
        item: result
      });
      var value = result.value;
      var sheng = result.provinces[value[0]];
      var shi = result.citys[value[1]];
      var xian = result.countys[value[2]];
      that.setData({
        'nature.address': sheng.label + shi.label + xian.label,
        'nature.addressCode': sheng.value + '-' + shi.value + '-' + xian.value
      });
    })
  },
  //滑动事件
  bindChange: function (e) {
    var that = this;
    model.pickScroll(e, this, function (result) {
      that.setData({
        item: result
      });

    });
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
  
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {
  
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
  
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {
  
  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {
  
  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {
  
  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {
  
  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {
  
  }
})